package view.utils {	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.utils.getQualifiedClassName;
	/**
	 * ...
	 * @author Anthony
	 */
	public /*abstract*/ class Tools
	{
		public function Tools() 
		{
			if(getQualifiedClassName(this) == "view.tools::Tools")
				throw new Error("Tools is abstract, you can't instanciate it directly.");
		}
		
		public static function getRepeatedBackgroundFromHeadCorpsFoot(head : BitmapData, corps : BitmapData, foot : BitmapData, totalHeight : Number) : Bitmap
		{
			var resultBackground : Bitmap = new Bitmap(new BitmapData(head.width, totalHeight));
			resultBackground.bitmapData.copyPixels(head, new Rectangle(0, 0, head.width, head.height), new Point(0, 0));
								
			var corpsCopyRectangle : Rectangle = new Rectangle(0, 0, corps.width, corps.height);
			for (var yRepeat : int = head.height ; yRepeat < (totalHeight - foot.height) ; yRepeat += corps.height)
			{				 
				resultBackground.bitmapData.copyPixels(corps, corpsCopyRectangle, new Point(0, yRepeat));				
			}
			
			resultBackground.bitmapData.copyPixels(foot, new Rectangle(0, 0, foot.width, foot.height), new Point(0, (totalHeight - head.height)));	
			
			return resultBackground;
		}
		
		
	}	
}